<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@include file="/jsp/commons/header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>销售分析系统</title>

    <script type="text/javascript" src="${ctx}/resources/js/datatable.js"></script>
    <%@ include file="/jsp/commons/meta.jsp"%>
    <script type="text/javascript">
    

        $(function(){

        	$("#insetRole").click(function(){
                $("#mainbody").load("${ctx}/role/toAddRole.htm");
            });

             $("#deleteRole").click(function(){
                 $("#tableshow tbody tr").each(function(){
                     $cell = $(this).find("td:eq(0)");
                     var current = $cell.find("input");
                     if(current[0].checked && confirm("确定要删除数据吗？")){
                          var text = $(this).find("td:eq(1)").text().trim();
                          $.ajax({
                              url: "${ctx}/role/deletetRole.htm",
                              data:{
                                  sid: text
                              },
                              success:function(){
                                  $("#mainbody").load("${ctx}/role/FindRoleList.htm");
                              }
                          });
                    }
                 });
              });

             $("#updateRole").click(function(){
                 $("#tableshow tbody tr").each(function(){
                      $cell = $(this).find("td:eq(0)");
                      var current = $cell.find("input");
                      if(current[0].checked){
                            var id = $(this).find("td:eq(1)").text().trim();
                            $("#mainbody").load(
                                 "${ctx}/role/FindRoleById.htm",
                                   {sid:id
                              	 }
                             );
                        }
                  });
              });
        });
    </script>
</head>
<body>
    <div id="container">
        <div id="tabs" class="content">权限修改</div>
        <div>
            <table cellpadding="0" cellspacing="0" border="0" class="message-table" id="tableshow">
                <thead>
                    <tr>
                        <td></td>
                        <th>id</th>
                        <th>用户名</th>
                        <th>说明</th>
                    </tr>
                </thead>

                <tbody>
                    <c:forEach items="${roles}" var="role">
                        <tr>
                            <td><input type="checkbox" id="checkbox"/></td>
                            <td>${role.sid}</td>
                            <td>${role.role_name}</td>
                            <td>${role.role_comments}</td>
                        </tr>
                    </c:forEach>
                </tbody>

                <tfoot>
                    <tr>
                        <th></th>
                        <th>id</th>
                        <th>用户名</th>
                        <th>说明</th>
                    </tr>
                </tfoot>
            </table>
            <div id="srid" align="right">
                <input type="button" id="insetRole" value="添加" />
                <input type="button" id="deleteRole" value="删除" /> 
                <input type="button" id="updateRole" value="修改" />
            </div>
          <div class="spacer">
          </div>
    </div>
</body>
</html>